﻿namespace Vin.Extension.Cache;

public interface ICache
{
    bool SetCache<T>(string key, T value, TimeSpan? expireTime = null);

    Task<bool> SetCacheAsync<T>(string key, T value, TimeSpan? expireTime = null);

    T? GetCache<T>(string key);

    Task<T?> GetCacheAsync<T>(string key);

    bool RemoveCache(string key);

    Task<bool> RemoveCacheAsync(string key);

    bool SetHashCache<T>(string key, string field, T value, TimeSpan? expireTime = null);

    Task<bool> SetHashCacheAsync<T>(string key, string field, T value, TimeSpan? expireTime = null);

    T? GetHashCache<T>(string key, string field);

    Task<T?> GetHashCacheAsync<T>(string key, string field);

    bool RemoveHashCache(string key, string field);

    Task<bool> RemoveHashCacheAsync(string key, string field);

    long GetHashCount(string key);

    Task<long> GetHashCountAsync(string key);

    long Incr(string key, TimeSpan? expireTime = null, bool firstSetExpire = true);
    
    Task<long> IncrAsync(string key, TimeSpan? expireTime = null, bool firstSetExpire = true);
}